package inet.app.controller.parser;

import inet.app.model.cau.Cau2;

import java.util.ArrayList;
public class Parser_Tk_Cau2_Resp {
	private String NAME = "TKCAU2_RESP";
	private ArrayList<Cau2> list = new ArrayList<Cau2>();
	
	public Parser_Tk_Cau2_Resp() {
	}
	
	public ArrayList<Cau2> getList(String json) {
		
		String[] data = json.split("\\|\\|\r\n");
		String[] item_first = data[0].split("\\|");
		
		String name = item_first[0];
		String status = item_first[1];
		String part="";
		
		if (status.equals("0") && name.equals(NAME)) {
			int i = 0;
			Cau2 item;
			String kqCau[] ;
			String last_update, code,date;
			int number = 0,vt1 = 0,vt2 = 0;
			
				kqCau = data[i].split("\\|");
				last_update= kqCau[2];
				code = kqCau[3];
				for (int j = 5; j < kqCau.length; j++) {
					number = Integer.parseInt(kqCau[j].split(":")[0]);
					vt1 = Integer.parseInt(kqCau[j].split(":")[1]);
					vt2 = Integer.parseInt(kqCau[j].split(":")[2]);
					item = new Cau2(number, vt1, vt2);
					list.add(item);
				}
				
				
			return list;
		} else
			return null;
	}

public String getString(String json) {
		String _result = null;
		String[] data = json.split("\\|\\|\r\n");
		System.out.println("DATA SIZE " + data.length);
		String[] item_first = data[0].split("\\|");
		
		String name = item_first[0];
		
		String status = item_first[1];
		if (status.equals("0") && name.equals(NAME)) {
			return json;
		} else
			return null;
	}


}
